package com.ficus.road.maintain.core.model;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ConfirmHitRequest {
    private ConfirmStatus status;
    private String confirmOpinion;

    public enum ConfirmStatus {
        CORRECT("CORRECT"),
        /* 不正确预警　*/
        INCORRECT("INCORRECT")
        ;

        private String value;

        ConfirmStatus(String value) {
            this.value = value;
        }

        @JsonCreator
        public static ConfirmHitRequest.ConfirmStatus fromValue(String value) {
            for (ConfirmHitRequest.ConfirmStatus b : ConfirmHitRequest.ConfirmStatus.values()) {
                if (b.value.equals(value)) {
                    return b;
                }
            }
            throw new IllegalArgumentException("Unexpected value '" + value + "'");
        }

        @Override
        @JsonValue
        public String toString() {
            return String.valueOf(value);
        }
    }
}
